<template>
  <div>
    <h2>我是Hello组件</h2>
    <p>父组件的数据{{helmsg}}</p>
    <p>根组件的数据{{helmsg2}}</p>
    <!-- <p>{{message}}</p> -->
    <!-- <p>{{obj.message}}</p> -->
    <p>Hello--{{newMsg}}</p>
  </div>
</template>
<script>
export default {
  data() {
    return {
      a: 10,
      helmsg: '',
      helmsg2: '',
    };
  },
  // inject: ['message'],
  // inject: ["obj"],
  inject: ['message'], //使用message函数,
  mounted(){
    this.helmsg = this.$parent.msg
    console.log(this.$parent.msg)
    this.helmsg2 = this.$root.msg
  },
  computed:{
    newMsg:function(){
      return this.message()
    }
  }
  
};
</script>``